package cn.xie.blog.serviceuser.common.util;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author: xiaoxie
 * create: 2025-04-23 10:41
 * @BelongsProject: blog-parent
 * @BelongsPackage: cn.xie.blog.serviceuser.common.util
 * description: 主要为了读取OSS的yml配置文件
 */
@Component
public class ConstantPropertiesUtil implements InitializingBean {
    @NacosValue(value = "${aliyun.oss.file.endpoint}", autoRefreshed = true)
    private String endpoint;
    @NacosValue(value = "${aliyun.oss.file.accessKeyId}", autoRefreshed = true)
    private String keyId;
    @NacosValue(value = "${aliyun.oss.file.accessKeySecret}", autoRefreshed = true)
    private String keySecret;
    @NacosValue(value = "${aliyun.oss.file.bucketName}", autoRefreshed = true)
    private String bucketName;


    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
    }
}
